gtk/textview: Defer touchscreen focus placing to drag end
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 20:07:54 +0000 (21:07 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 20:29:20 +0000 (21:29 +0100)
With the scrolledwindow drag gesture not claiming the sequence immediately,
we end up placing the cursor (and undoing the previous selection) each time
we scroll.

There is already handling too short drags in ::drag-end, so let this code
handle touchscreens as well.

gtk/gtktextview.c

index bf3a2b30e369d62aca6cc006237bc13ca4eaa0f8..152238e2e26452cf3b36c294f7656d4af37a89a5 100644 (file)
@@ -5473,10 +5473,7 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
                 gtk_text_view_selection_bubble_popup_unset (text_view);
 
                 if (is_touchscreen)
-                  {
-                    gtk_text_buffer_place_cursor (get_buffer (text_view), &iter);
-                    priv->handle_place_time = g_get_monotonic_time ();
-                  }
+                  priv->handle_place_time = g_get_monotonic_time ();
                 else
                   gtk_text_view_start_selection_drag (text_view, &iter,
                                                       SELECT_CHARACTERS, extends);
@@ -7371,7 +7368,7 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
   is_touchscreen = gtk_simulate_touchscreen () ||
     gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
 
-  if (!is_touchscreen && clicked_in_selection &&
+  if ((is_touchscreen || clicked_in_selection) &&
       !gtk_drag_check_threshold (GTK_WIDGET (text_view), start_x, start_y, x, y))
     {
       GtkTextIter iter;